﻿<%@ Page Language="C#" MasterPageFile="~/Master.master" AutoEventWireup="true" CodeFile="Clientes.aspx.cs" Inherits="Clientes_Clientes" Title="Untitled Page" %>

<script runat="server">
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContenidoPrincipal" Runat="Server">
    <table class="Tabla" style="width: 439px">
        <tr>
            <td align="center" colspan="4" style="height: 15px" class="Titulo">
                INFORMACION GENERAL DEL PRODUCTO</td>
        </tr>
        <tr>
            <td style="width: 300px; height: 15px">
                RAZON SOCIAL</td>
            <td style="width: 16px; height: 15px">
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtRazonSocial"
                    Display="Dynamic" ErrorMessage="Ingrese el Nombre del Producto" 
                    SetFocusOnError="True" ValidationGroup="Grabar">*</asp:RequiredFieldValidator></td>
            <td style="height: 15px">
                <asp:TextBox ID="txtRazonSocial" runat="server" CssClass="TextBox" 
                    Width="213px" Font-Bold="False" MaxLength="100"></asp:TextBox></td>
            <td align="center" rowspan="3">
                <asp:Image ID="imgFoto" runat="server" Height="60px" Width="60px" 
                    ImageUrl="~/images/noImage.jpg" />
                </td>
        </tr>
        <tr>
            <td style="width: 300px; height: 7px">
                FOTO</td>
            <td style="width: 16px; height: 7px">
                &nbsp;</td>
            <td style="height: 7px">
                <asp:FileUpload ID="fupFoto" runat="server" />
&nbsp;
                </td>
        </tr>
        <tr>
            <td style="width: 300px">
                EPC</td>
            <td style="width: 16px">
                &nbsp;</td>
            <td>
                <asp:TextBox ID="txtEpc" runat="server" CssClass="TextBox" Width="213px" 
                    Font-Bold="False" MaxLength="50"></asp:TextBox></td>
        </tr>
        <tr>
            <td style="width: 300px">
                &nbsp;</td>
            <td style="width: 16px">
            </td>
            <td>
                <asp:CheckBox ID="chkActivo" runat="server" Text="Activo" Font-Bold="False" 
                    Checked="True" /></td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td style="width: 300px; height: 22px;">
            </td>
            <td style="width: 16px; height: 22px;">
                &nbsp;</td>
            <td align="right" style="height: 22px">
                &nbsp;</td>
            <td align="right" style="height: 22px">
                <asp:Button ID="btnGrabar" runat="server" CssClass="Boton" OnClick="btnGrabar_Click"
                    Text="Grabar" ValidationGroup="Grabar" /></td>
        </tr>
    </table>
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" CssClass="Label" ShowMessageBox="True"
        ShowSummary="False" ValidationGroup="Grabar" />
    <table style="width: 688px">
        <tr>
            <td style="width: 100%; border-bottom: #5D7B9D thin solid">
            </td>
        </tr>
    </table>
    <table style="width: 521px" class="Tabla">
        <tr>
            <td align="center" style="height: 15px" class="Titulo">
                LISTADO DE CLIENTES</td>
        </tr>
        <tr>
            <td style="height: 15px">
            <div style="overflow: auto; width: 556px; height: 276px">
                <asp:GridView ID="grdClientes" runat="server" AllowSorting="True" 
                    AutoGenerateColumns="False" DataSourceID="sdsClientes" 
                    Width="518px" OnSelectedIndexChanged="grdProductos_SelectedIndexChanged" 
                    DataKeyNames="ID">
                    <Columns>
                        <%--<asp:BoundField DataField="RAZONSOCIAL" HeaderText="RAZONSOCIAL" 
                            SortExpression="RAZONSOCIAL" />--%>
                        <%--<asp:BoundField DataField="RAZONSOCIAL" HeaderText="RAZON SOCIAL" 
                            SortExpression="RAZONSOCIAL" >
                            <ItemStyle HorizontalAlign="Left" />
                        </asp:BoundField>--%>
                        <asp:TemplateField HeaderText="RAZON SOCIAL" SortExpression="RAZONSOCIAL">
                            <ItemTemplate>
                                <asp:LinkButton ID="btnNombre" runat="server" CommandName="Select" Text='<%# Bind("RAZONSOCIAL") %>' Width="231px" CssClass="Link"></asp:LinkButton>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Left" />
                        </asp:TemplateField>
                        <asp:BoundField DataField="FOTO" HeaderText="FOTO" SortExpression="FOTO" />
                        <asp:BoundField DataField="EPC" HeaderText="EPC" SortExpression="EPC" >
                        </asp:BoundField>
                        <asp:TemplateField HeaderText="Activo" SortExpression="ACTIVO">
                            <ItemTemplate>
                                <asp:CheckBox ID="chkActivo" runat="server" Checked='<%# Bind("ACTIVO") %>' Enabled="false" />
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                    </Columns>
                    <RowStyle HorizontalAlign="Center" CssClass="RowStyle" />
                    <HeaderStyle HorizontalAlign="Center" CssClass="HeaderStyle" ForeColor="White" />
                    <FooterStyle CssClass="FooterStyle" />
                    <EditRowStyle CssClass="EditRowStyle" />
                    <SelectedRowStyle CssClass="SelectedRowStyle" />
                    <PagerStyle CssClass="PagerStyle" />
                    <AlternatingRowStyle CssClass="AlternatingRowStyle" />
                </asp:GridView>
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <asp:SqlDataSource ID="sdsClientes" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:CEDIS %>" 
                    
                    
                    SelectCommand="SELECT ID, RAZONSOCIAL, FOTO, EPC, ACTIVO FROM CLIENTE" 
                    
                    InsertCommand="INSERT INTO CLIENTE(RAZONSOCIAL, FOTO, EPC, ACTIVO) VALUES (@RazonSocial, @Foto, @Epc, @Activo)" 
                    
                    UpdateCommand="UPDATE CLIENTE SET RAZONSOCIAL = @RazonSocial, FOTO = @Foto, EPC = @Epc, ACTIVO = @Activo WHERE (ID = @Id)">
                    <UpdateParameters>
                        <asp:ControlParameter ControlID="txtRazonSocial" Name="RazonSocial" 
                            PropertyName="Text" />
                        <asp:Parameter Name="Foto" />
                        <asp:ControlParameter ControlID="txtEpc" Name="Epc" PropertyName="Text" />
                        <asp:ControlParameter ControlID="chkActivo" Name="Activo" 
                            PropertyName="Checked" />
                        <asp:ControlParameter ControlID="grdClientes" DefaultValue="" Name="Id" 
                            PropertyName="SelectedValue" />
                    </UpdateParameters>
                    <InsertParameters>
                        <asp:ControlParameter ControlID="txtRazonSocial" Name="RazonSocial" 
                            PropertyName="Text" />
                        <asp:Parameter Name="Foto" />
                        <asp:ControlParameter ControlID="txtEpc" Name="Epc" PropertyName="Text" />
                        <asp:ControlParameter ControlID="chkActivo" Name="Activo" 
                            PropertyName="Checked" />
                    </InsertParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
    </table>
</asp:Content>

